import 'package:flutter/material.dart';
import 'package:flutter_widget/src/widget/effect/card_widget.dart';
import 'package:flutter_widget/src/widget/effect/gradient_color_widget.dart';
import 'package:flutter_widget/src/widget/image/web_cache_Image.dart';

///渐变卡片
class GradientCardWidget extends StatelessWidget {
  final String backgroundUrl;
  final List<Color>? colors;

  const GradientCardWidget({
    Key? key,
    required this.backgroundUrl,
    this.colors,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CardWidget(
      radius: 4,
      shadowElevation: 10,
      child: Stack(
        fit: StackFit.expand,
        children: [
          WebCacheImage(
            imageUrl: backgroundUrl,
            fit: BoxFit.cover,
          ),
          Positioned.fill(
            child:GradientColorWidget(
              colors: colors ??
                  const [
                    Color(0x90FFFFFF),
                    Color(0xAAFFFFFF),
                    Color(0xEEFFFFFF),
                    Color(0xFFFFFFFF),
                    Color(0xFFFFFFFF),
                    Color(0xFFFFFFFF),
                    Color(0xFFFFFFFF),
                    Color(0xFFFFFFFF)
                  ],
              fromPosition: Alignment.topRight,
              toPosition: Alignment.bottomCenter,
            ),
          ),
        ],
      ),
    );
  }
}
